package com.numberone.system.service.impl;

import java.util.List;

import com.numberone.system.domain.XyOrder;
import com.numberone.system.mapper.XyOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.numberone.system.mapper.AssessMapper;
import com.numberone.system.domain.Assess;
import com.numberone.system.service.IAssessService;
import com.numberone.common.support.Convert;

/**
 * 商品评价 服务层实现
 * 
 * @author numberone
 * @date 2020-10-13
 */
@Service
public class AssessServiceImpl implements IAssessService 
{
	@Autowired
	private AssessMapper assessMapper;
	@Autowired
	private XyOrderMapper xyOrderMapper;

	/**
     * 查询商品评价信息
     * 
     * @param id 商品评价ID
     * @return 商品评价信息
     */
    @Override
	public Assess selectAssessById(Long id)
	{
	    return assessMapper.selectAssessById(id);
	}
	
	/**
     * 查询商品评价列表
     * 
     * @param assess 商品评价信息
     * @return 商品评价集合
     */
	@Override
	public List<Assess> selectAssessList(Assess assess)
	{
	    return assessMapper.selectAssessList(assess);
	}
	
    /**
     * 新增商品评价
     * 
     * @param assess 商品评价信息
     * @return 结果
     */
	@Override
	public int insertAssess(Assess assess)
	{
		XyOrder xyOrder = xyOrderMapper.selectXyOrderById(assess.getOrderId());
		System.out.println(xyOrder.getOrderNumber() +"==============");
		assessMapper.insertAssess(assess);
		xyOrder.setIsAssess(1);
		return xyOrderMapper.updateXyOrder(xyOrder);
	}
	
	/**
     * 修改商品评价
     * 
     * @param assess 商品评价信息
     * @return 结果
     */
	@Override
	public int updateAssess(Assess assess)
	{
	    return assessMapper.updateAssess(assess);
	}

	/**
     * 删除商品评价对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteAssessByIds(String ids)
	{
		return assessMapper.deleteAssessByIds(Convert.toStrArray(ids));
	}
	
}
